<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		 <style>
        div {
            width: 1210px;
            margin: 200px auto;
            color: red;
            text-align: center;
            font: 600 30px/30px "simsun";
        }
    </style>
	</head>
	<body>
		<div>
		</div>
	</body>
	<script>
		var div=document.getElementsByTagName("div")[0];
		setInterval(fn,1);
		function fn(){
			var nowtime=new Date();
			var future=new Date("2024/08/20 24:00:00");
			var timeSum=future.getTime()-nowtime.getTime();
			var day=parseInt(timeSum/1000/60/60/24)
			var hour=parseInt(timeSum/1000/60/60%24)
			var minu=parseInt(timeSum/1000/60%60)
			var sec=parseInt(timeSum/1000%60)
			var milsec=parseInt(timeSum%1000)

			var formattedMilsec = milsec < 10 ? "00" + milsec : milsec < 100 ? "0" + milsec : milsec;
			div.innerHTML = "距离下课吃饭还有" + day + "天" + hour + "小时" + minu + "分"
                        + sec + "秒" + formattedMilsec + "毫秒";
		}
		//bug :补前面的0
	</script>
</html>
